﻿using System;
using System.Web.Services;
using StampController.BL;
using StampController.BL.Models;
using StampController.Helpers;

namespace StampController.Pages
{
    public partial class Feedback : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                var user = SessionUtils.Get<UsersModel>("USER");
                if (user == null)
                    Response.Redirect("/");
            }
        }

        [WebMethod]
        public static bool SaveFeedback(FeedbackModel feedback)
        {
            var user = SessionUtils.Get<UsersModel>("USER");
            if (user == null)
            {
                return false;
            }
            var im = new FeedbackFormImpl();
            feedback.UserID = user.UserID;
            feedback.FeedbackTime = DateTime.Now;
            return im.SaveFeedback(feedback);
        }
    }
}